package com.aspsine.multithreaddownload.demo.util;


import ohos.app.Context;
import ohos.app.Environment;

import java.io.File;

/**
 * Created by aspsine on 15-4-19.
 */
public class FileUtils {
    private static final String DOWNLOAD_DIR = "download";

    public static final File getDownloadDir(Context context) {
        //TODO
//        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        //if (Environment.().equals(Environment.MEDIA_MOUNTED)) {
           // return new File(context.getExternalCacheDir(), DOWNLOAD_DIR);
      //  }
        return new File(context.getExternalFilesDir(null).getParentFile().getAbsolutePath(),
        DOWNLOAD_DIR);
    }


    public static final String getPrefix(String fileName) {

        return fileName.substring(0, fileName.lastIndexOf("."));
    }

    public static final String getSuffix(String fileName) {

        return fileName.substring(fileName.lastIndexOf(".") + 1);
    }
}
